#include "startgame.h"
#include "ui_startgame.h"
#include"mainscence.h"
#include<QSound>
#include<QMessageBox>

QSound* sound = new QSound(MENUMUSIC_PATH);


startGame::startGame(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::startGame)
{

    ui->setupUi(this);

/*******************/

    sound->setLoops(QSound::Infinite);
    sound->play();

/*******************/

}

startGame::~startGame()
{
    delete ui;
}

void startGame::initScene()
{
    //设置窗口固定尺寸
    setFixedSize(MENU_WIDTH,MENU_HEIGHT);//后期大小只需在h文件中修改即可

    menu_background.load(MENU_BACKGROUND);
    //设置标题
    setWindowTitle(START_GAME_TITLE);

    //加载图标
    setWindowIcon(QIcon(START_GAME_ICON));


}

void startGame::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    painter.drawPixmap(rect(),QPixmap(MENU_BACKGROUND),QRect());

}

void startGame::on_pushButton_clicked()
{
    this->hide();
    QMessageBox::about(this,"游戏规则","1、用鼠标拖动或wasd控制战机移动 2、按住L键进入子弹时间 3、按P键暂停，按空格键开始");
    sound->stop();
    emit nextPage();
}

void startGame::last()
{
    this->show();
}
